﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bymed.SpineScan.Service.Interface
{
    /// <summary>
    /// An instance of IService against the specific DataModel type and performs validation.
    /// </summary>
    /// <typeparam name="T">The specific DataModel type.</typeparam>
    public interface IDataValidator<T>
    {
        /// <summary>
        /// Add a error into current dictionary.
        /// </summary>
        /// <param name="key">The key of the dictionary.</param>
        /// <param name="errorMessage">The error message will be added into the dictionary.</param>
        void AddError(string key, string errorMessage);

        /// <summary>
        /// Get a error from current dictionary.
        /// </summary>
        /// <param name="key">The key of the dictionary.</param>
        /// <returns>The matched error message will be return if it exists. Otherwise the result will be null.</returns>
        string GetError(string key);

        /// <summary>
        /// Get the IEnumerable collection contains all error keys.
        /// </summary>
        /// <returns>IEnumerable collection contains all error keys.</returns>
        IEnumerable GetAllErrorKeys();

        /// <summary>
        /// True means it's valid. False means invalid.
        /// </summary>
        bool IsValid { get; }

        /// <summary>
        /// Validate the provided entity. Then check the IsValid property to see the result.
        /// </summary>
        /// <param name="entity">The provided entity to be validated.</param>
        void Validate(T entity);
    }
}
